import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_utils/get_utils.dart';

class APIPage extends GetView {

  @override
  Widget build(BuildContext context) {
    String myEmail = 'abcxyz.com';

    return Scaffold(
      appBar: AppBar(title: Text('APIPage')),

      body: SafeArea(
        child: ListView(
          children: [
            Text("页面宽度: "+Get.width.toString()),
            ListTile(
              title: Text('bottomSheet: '+Get.isBottomSheetOpen.toString()),
              subtitle: Text('Get.bottomSheet(...)'),
              trailing: Icon(Icons.chevron_right_outlined),
              onTap: () {
                Get.bottomSheet(
                  Container(
                    child: Wrap(
                      children: <Widget>[
                        ListTile(
                          leading: Icon(Icons.music_note),
                          title: Text('Music'),
                          onTap: () => {}
                        ),
                        ListTile(
                          leading: Icon(Icons.videocam),
                          title: Text('Video'),
                          onTap: () => {},
                        ),
                      ],
                    ),
                  ),
                  backgroundColor: Colors.white
                );
                Get.snackbar('底部状态', Get.isBottomSheetOpen.toString());
              }
            ),
            Text("横屏: "+context.isLandscape.toString()),
            Text("竖屏: "+context.isPortrait.toString()),
            ListTile(
              title: Text('isEmail: '+myEmail),
              subtitle: Text('GetUtils.isEmail(myEmail)'),
              trailing: Icon(Icons.chevron_right_outlined),
              onTap: () {
                Get.snackbar('邮箱格式', GetUtils.isEmail(myEmail).toString());
              }
            ),
            Text("是否是Web："+GetPlatform.isWeb.toString()),
            Text("是否是安卓："+GetPlatform.isAndroid.toString()),
            Text("是否是iOS："+GetPlatform.isIOS.toString()),
            Text("是否是Windows："+GetPlatform.isWindows.toString()),
          ],
        )
      ),
    );
  }
}